import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class FireNet {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        Queue<Integer> queue = new LinkedList<>();
        while (true) {
            // 读取第一个数字，表示矩阵的大小
            int n = scanner.nextInt();
            if (n == 0) {
                break;
            }
            // 构造 n 行 n 列的矩阵，读取 n 行数据
            int[][] matrix = new int[n][n];
            for (int i = 0; i < n; i++) {
                String line = scanner.next(); // 读取矩阵的一行
                char[] chas = line.toCharArray();
                for (int m = 0; m < chas.length; m++) {
                    if (chas[m] == '.') {
                        matrix[i][m] = 0;//可达点
                    } else if (chas[m] == 'x' || chas[m] == 'X') {
                        matrix[i][m] = 2;//路障
                    }
                }
            }
            queue.add(findMaxPlacements(matrix));
        }
//        输出结果
        while (!queue.isEmpty())
            System.out.printf(queue.poll().toString() + '\n');
        scanner.close(); // 关闭输入流
    }

    public static int findMaxPlacements(int[][] matrix) {
        // 基于回溯 + 剪枝求解最大放置点数
        return backtrack(matrix, 0, 0);
    }

    public static int backtrack(int[][] matrix, int row, int col) {
        // 递归终止条件
        if (row == matrix.length) return 0;

        // 计算下一个位置
        int nextRow = (col == matrix[0].length - 1) ? row + 1 : row;
        int nextCol = (col == matrix[0].length - 1) ? 0 : col + 1;

        // 跳过已经有障碍的单元格
        if (matrix[row][col] == 2) {
            return backtrack(matrix, nextRow, nextCol);
        }

        // 检查是否可以放点
        int maxValue = backtrack(matrix, nextRow, nextCol);
        if (canPlace(matrix, row, col)) {
            place(matrix, row, col, 1); // 放置点
            maxValue = Math.max(maxValue, 1 + backtrack(matrix, nextRow, nextCol));
            place(matrix, row, col, 0); // 撤销放置
        }

        return maxValue;
    }

    public static boolean canPlace(int[][] matrix, int row, int col) {
        // 检查当前行、列是否有冲突点
        return checkDirection(matrix, row, col, -1, 0) &&
                checkDirection(matrix, row, col, 1, 0) &&
                checkDirection(matrix, row, col, 0, -1) &&
                checkDirection(matrix, row, col, 0, 1);
    }

    public static boolean checkDirection(int[][] matrix, int row, int col, int dx, int dy) {
        // 检查某个方向上的合法性
        int x = row + dx, y = col + dy;
        while (x >= 0 && x < matrix.length && y >= 0 && y < matrix[0].length) {
            if (matrix[x][y] == 2) break;     // 路障
            if (matrix[x][y] == 1) return false; // 冲突点
            x += dx;
            y += dy;
        }
        return true;
    }

    public static void place(int[][] matrix, int row, int col, int value) {
        matrix[row][col] = value;
    }
}
